package de.jmda.gui.swing.mvc;

import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;

import javax.annotation.processing.Processor;

import org.junit.Test;

import de.jmda.mproc.JUTProcessor;
import de.jmda.mproc.Launcher;

public class JUTControllerSupportEnabledProcessorJV6 extends JUTProcessor
{
	@Test
	public void testProcessor()
	{
		Processor processor = new ControllerSupportEnabledProcessor();

		launchConfiguration.files.addAll(getJavaFilesWithSupportedAnnotation());
		launchConfiguration.processors.add(processor);
		
		try
    {
	    assertTrue(
	    		"unexpected return value for launch of " +
	    		processor.getClass().getName(),
	    		Launcher.launch(launchConfiguration));
    }
    catch (IOException e)
    {
    	fail(
    			"failure launching annotation processor [" +
    			processor.getClass().getName() + "]\n" + e);
    }
	}

	@Override
  protected List<File> getJavaFilesWithSupportedAnnotation()
  {
		return
				Arrays.asList
				(
					new File[]
					{
						new File(
								getSourceRoot().getAbsolutePath() + "/" +
								MarkedType.class.getPackage().getName().replace('.', '/') + "/" +
								MarkedType.class.getSimpleName() + ".java")
					}
				);
  }
}